package com.briup.jdbc.conn;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;

public class JDBCPool {

	private static ConnectionImpl connectionImpl = new ConnectionImpl();

	public synchronized static Connection getConn() throws SQLException, InterruptedException {
		UpConnection upConn = connectionImpl.getConn();
		return upConn.conn;
	}

	public synchronized static void commit(Connection conn) throws SQLException {
		UpConnection upConn = new UpConnection();
		upConn.recentUsedTime = new Date();
		upConn.conn = conn;
		connectionImpl.commit(upConn);
	}

	public static void rollback(Connection conn) throws SQLException {
		UpConnection upConn = new UpConnection();
		upConn.recentUsedTime = new Date();
		upConn.conn = conn;
		connectionImpl.rollback(upConn);
	}

	public static void close(Connection conn) throws InterruptedException, SQLException {
		UpConnection upConn = new UpConnection();
		upConn.recentUsedTime = new Date();
		upConn.conn = conn;
		connectionImpl.close(upConn);
	}

}
